package com.itheima.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.itheima.mapper.MenuMapper;
import com.itheima.pojo.Menu;
import com.itheima.service.MenuService;
import com.mysql.jdbc.StringUtils;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @Description 菜单服务接口实现类
 * @Author makun
 * @Date 2023/10/20 14:46
 * @Version 1.0
 */
@Service
public class MenuServiceImpl extends ServiceImpl<MenuMapper, Menu> implements MenuService {
    @Override
    public List<Menu> getMenus(String queryString) {
        return baseMapper.selectList(new LambdaQueryWrapper<Menu>()
                .like(!StringUtils.isNullOrEmpty(queryString),Menu::getName, queryString)
                .orderByAsc(Menu::getPriority));
    }

    @Override
    public List<Menu> getAllMenusAsTree() {
        return baseMapper.selectAllMenuToTree();
    }
}
